home *** CD-ROM | disk | FTP | other *** search
/ Greenhouse Effect Detection Expriment / NASA Greenhouse Effect Detection Expriment 1992 - Disc 2.iso / software / dos / cdf22pc / src / include / cdfdist.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-01  |  6.2 KB  |  240 lines

  1. /******************************************************************************
  2. *
  3. *  NSSDC/CDF                Header file for CDF distribution.
  4. *
  5. *  Version 2.0, 2-Mar-92, ST Systems (STX)
  6. *
  7. *  Modification history:
  8. *
  9. *   V1.0  20-Jul-91, J Love    Original version (for CDF V2.1).
  10. *   V2.0   2-Mar-92, J Love    IBM PC & HP-UX port.  CDF V2.2.
  11. *
  12. ******************************************************************************/
  13.  
  14. #if !defined(___cdfdist_h___)
  15. #define ___cdfdist_h___
  16.  
  17. /*****************************************************************************
  18. * Definitions for misguided IBM PC compilers.
  19. *****************************************************************************/
  20.  
  21. #if defined(MSDOS)                    /* For MicroSoft C */
  22. #define __MSDOS__
  23. #endif
  24.  
  25. /******************************************************************************
  26. * System include files.
  27. ******************************************************************************/
  28.  
  29. #if defined(unix)
  30. #include <sys/types.h>
  31. #endif
  32.  
  33. #if defined(__MSDOS__)
  34. #include <sys\\types.h>
  35. #endif
  36.  
  37. #if defined(vms)
  38. #include <types.h>
  39. #endif
  40.  
  41. #include <stdlib.h>
  42. #include <stdio.h>
  43. #include <string.h>
  44. #include <ctype.h>
  45. #include <time.h>
  46. #include <math.h>
  47.  
  48. #if defined(__MSDOS__)
  49. #include <stdarg.h>
  50. #else
  51. #include <varargs.h>
  52. #endif
  53.  
  54. /*****************************************************************************
  55. * Typedefs.
  56. *****************************************************************************/
  57.  
  58. typedef int  Boolean;
  59.  
  60. #if defined(AIX) | defined(__MSDOS__)
  61. typedef signed char    Schar;
  62. typedef signed char    Byte;
  63. #else
  64. typedef char        Schar;
  65. typedef char        Byte;
  66. #endif
  67.  
  68. typedef unsigned char    Uchar;
  69.  
  70. /******************************************************************************
  71. * Non-system include files.
  72. ******************************************************************************/
  73.  
  74. #include "cdf.h"
  75. #include "dirutils.h"
  76. #include "qop.h"
  77. #include "epochu.h"
  78.  
  79. /*****************************************************************************
  80. * ASCII characters.
  81. *****************************************************************************/
  82.  
  83. #define NUL    '\0'        /* Null character. */
  84.  
  85. /*****************************************************************************
  86. * Standards.
  87. *****************************************************************************/
  88.  
  89. #define NSSDC_STANDARD        1    /* when TRUE (1), assume that all
  90.                        CDFs conform to NSSDC standard
  91.                        (by default) */
  92.  
  93. /*****************************************************************************
  94. * Operating system dependent functions.
  95. *****************************************************************************/
  96.  
  97. #if defined(__MSDOS__)
  98. #define EXIT_SUCCESS 0
  99. #define EXIT_FAILURE 1
  100. #define cfree free        /* 'cfree' not available on IBM-PC */
  101. #define Exit exit(EXIT_SUCCESS)
  102. #define ExitBAD exit(EXIT_FAILURE)
  103. #endif
  104.  
  105. #if defined(unix)
  106. #if !defined(memmove)
  107. #define memmove(dst,src,nbytes) bcopy(src,dst,nbytes)
  108. #endif
  109. #define Exit exit(0)
  110. #define ExitBAD exit(1)
  111. #endif
  112.  
  113. #if defined(vms)
  114. #include <ssdef.h>
  115. #define Exit exit(SS$_NORMAL)
  116. #define ExitBAD exit(SS$_ABORT)
  117. #endif
  118.  
  119. /*****************************************************************************
  120. * Machine dependent definitions.
  121. *****************************************************************************/
  122.  
  123. #if defined(__MSDOS__)
  124. #define __IBMPC__        /* Used to check for IBM PC data encoding. */
  125. #endif
  126.  
  127. #if defined(SunOS_403)
  128. #if !defined(toupper)
  129. #define toupper(c) ((c)&0x5F)
  130. #endif
  131. #endif
  132.  
  133. /*****************************************************************************
  134. * Miscellaneous macros.
  135. *****************************************************************************/
  136.  
  137. #define setbit(a,bit) (a = a | (1 << bit))
  138. #define clrbit(a,bit) (a = a & ~(1 << bit))
  139.  
  140. #define bitset(a,bit) (a & (1 << bit))
  141. #define bitclr(a,bit) ( ! (a & (1 << bit)))
  142.  
  143. #if !defined(Minimum)
  144. #define Minimum(a,b) ((a) < (b) ? (a) : (b))
  145. #endif
  146.  
  147. #if !defined(Maximum)
  148. #define Maximum(a,b) ((a) > (b) ? (a) : (b))
  149. #endif
  150.  
  151. #if !defined(TRUE)
  152. #define TRUE (-1)
  153. #endif
  154.  
  155. #if !defined(FALSE)
  156. #define FALSE 0
  157. #endif
  158.  
  159. #if !defined(SEEK_SET)
  160. #define SEEK_SET 0
  161. #endif
  162.  
  163. #if !defined(SEEK_CUR)
  164. #define SEEK_CUR 1
  165. #endif
  166.  
  167. #if !defined(SEEK_END)
  168. #define SEEK_END 2
  169. #endif
  170.  
  171. /******************************************************************************
  172. * MACRO to check if a character string data type.
  173. ******************************************************************************/
  174.  
  175. #define STRINGdataType(dataType) \
  176. (dataType == CDF_CHAR || dataType == CDF_UCHAR)
  177.  
  178. /******************************************************************************
  179. * MALLOC macro.
  180. ******************************************************************************/
  181.  
  182. #define MALLOC(ptr,size) { \
  183. ptr = (void *) malloc ((size_t) size); \
  184. if (ptr == NULL) { \
  185.   printf ("Unable to allocate dynamic memory, halting...\n"); \
  186.   ExitBAD; \
  187. } \
  188. }
  189.  
  190. /******************************************************************************
  191. * nCHARACTERS macro.  Outputs `n' of the specified character to a file pointer.
  192. ******************************************************************************/
  193.  
  194. #define nCHARACTERS(fp,nChars,character) { \
  195. int _i_; \
  196. for (_i_ = 0; _i_ < nChars; _i_++) fprintf (fp,"%c",character); \
  197. }
  198.  
  199. /******************************************************************************
  200. * Function prototypes.
  201. ******************************************************************************/
  202.  
  203. #if defined(vms) | defined(__MSDOS__)
  204. void PageInst (char **);
  205. char PickDelim (char *);
  206. int ElemSize (long);
  207. int EncodeString (long, char *, char *);
  208. int EncodeValue (long, void *, char *);
  209. void WriteStringValue (FILE *, long, void *, int, int);
  210. void WriteEntryValue (FILE *, long, long, void *, int, int);
  211. char *EncodingToken (long);
  212. char *MajorityToken (long);
  213. char *FormatToken (long);
  214. char *ScopeToken (long);
  215. char *VarianceToken (long);
  216. char *TFvarianceToken (long);
  217. char *DataTypeToken (long);
  218. #endif
  219.  
  220. #if defined(unix)
  221. void PageInst ();
  222. char PickDelim ();
  223. int ElemSize ();
  224. int EncodeString ();
  225. int EncodeValue ();
  226. void WriteStringValue ();
  227. void WriteEntryValue ();
  228. char *EncodingToken ();
  229. char *MajorityToken ();
  230. char *FormatToken ();
  231. char *ScopeToken ();
  232. char *VarianceToken ();
  233. char *TFvarianceToken ();
  234. char *DataTypeToken ();
  235. #endif
  236.  
  237. /*****************************************************************************/
  238.  
  239. #endif    /*___cdfdist_h___*/
  240.